#include <iostream>
#include <vector>


struct Point {
	long long x, y, z;
};

inline int Find(const int i, std::vector<int>& father) {
	if (father[i] != i) {
		father[i] = Find(father[i], father);
	}

	return father[i];
}

inline void Union(const int x, const int y, std::vector<int>& father) {
	const int fx = Find(x, father);
	if (const int fy = Find(y, father); fx != fy) {
		father[fx] = fy;
	}
}


inline long long GetDist(const Point& p1, const Point& p2) {
	return (p1.x - p2.x) * (p1.x - p2.x) +
		(p1.y - p2.y) * (p1.y - p2.y) +
		(p1.z - p2.z) * (p1.z - p2.z);
}

/**
 * 奶酪
 */
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int T;
	std::cin >> T;

	for (int i = 0; i < T; i++) {
		int n;
		long long h, r;
		std::cin >> n >> h >> r;

		std::vector<Point> points(n);
		std::vector<int> lower;
		std::vector<int> higher;

		std::vector<int> father(n);

		for (int j = 0; j < n; j++) {
			std::cin >> points[j].x >> points[j].y >> points[j].z;
			father[j] = j;

			if (points[j].z <= r) {
				lower.push_back(j);
			}

			if (points[j].z + r >= h) {
				higher.push_back(j);
			}
		}

		const long long distThreshold = 4LL * r * r;
		for (int j = 0; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (GetDist(points[j], points[k]) <= distThreshold) {
					Union(j, k, father);
				}
			}
		}


		bool isConnected = false;
		for (const int j : lower) {
			for (const int k : higher) {
				if (Find(j, father) == Find(k, father)) {
					isConnected = true;
					break;
				}
			}
			if (isConnected) {
				break;
			}
		}

		if (isConnected) {
			std::cout << "Yes\n";
		}else {
			std::cout << "No\n";
		}
	}


	return 0;
}
